<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>mydemo</title>
	<style type="text/css">
		div {width:50px;margin:10px auto;text-align:center;}
		input {width:30px;cursor:pointer;}
	</style>
	<script type="text/javascript">
		window.onload = function() {
			/*此时已经获取到确定的元素*/
			var oInput = document.getElementsByTagName("input")[0];
			console.log(oInput);/*获取到的是元素*/
			/*按钮的事件*/
			function sum() {
				var sum = parseInt(oInput.value);
				var i = 1;
				return(sum += i);/*此处需要设置返回值，onclick事件中alert和value需要用到该返回值*/
			}
			oInput.onclick = function() {
				console.log(this.value);/*此时value为初始字符，需要转换为数字型*/
				alert(sum());
				this.value = sum();

			}
		}
	</script>
</head>
<body>
	<div>
	<input type="button" value="0">
	</div>
</body>
</html>